package com.ruoyi.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.domain.AppMediumActivityTag;
import com.ruoyi.app.service.IAppMediumActivityTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动与自选标签的关联Controller
 * 
 * @author ruoyi
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/app/tag")
public class AppMediumActivityTagController extends BaseController
{
    @Autowired
    private IAppMediumActivityTagService appMediumActivityTagService;

    /**
     * 查询活动与自选标签的关联列表
     */
    @PreAuthorize("@ss.hasPermi('app:tag:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppMediumActivityTag appMediumActivityTag)
    {
        startPage();
        List<AppMediumActivityTag> list = appMediumActivityTagService.selectAppMediumActivityTagList(appMediumActivityTag);
        return getDataTable(list);
    }

    /**
     * 导出活动与自选标签的关联列表
     */
    @PreAuthorize("@ss.hasPermi('app:tag:export')")
    @Log(title = "活动与自选标签的关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppMediumActivityTag appMediumActivityTag)
    {
        List<AppMediumActivityTag> list = appMediumActivityTagService.selectAppMediumActivityTagList(appMediumActivityTag);
        ExcelUtil<AppMediumActivityTag> util = new ExcelUtil<AppMediumActivityTag>(AppMediumActivityTag.class);
        util.exportExcel(response, list, "活动与自选标签的关联数据");
    }

    /**
     * 获取活动与自选标签的关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:tag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appMediumActivityTagService.selectAppMediumActivityTagById(id));
    }

    /**
     * 新增活动与自选标签的关联
     */
    @PreAuthorize("@ss.hasPermi('app:tag:add')")
    @Log(title = "活动与自选标签的关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppMediumActivityTag appMediumActivityTag)
    {
        return toAjax(appMediumActivityTagService.insertAppMediumActivityTag(appMediumActivityTag));
    }

    /**
     * 修改活动与自选标签的关联
     */
    @PreAuthorize("@ss.hasPermi('app:tag:edit')")
    @Log(title = "活动与自选标签的关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppMediumActivityTag appMediumActivityTag)
    {
        return toAjax(appMediumActivityTagService.updateAppMediumActivityTag(appMediumActivityTag));
    }

    /**
     * 删除活动与自选标签的关联
     */
    @PreAuthorize("@ss.hasPermi('app:tag:remove')")
    @Log(title = "活动与自选标签的关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appMediumActivityTagService.deleteAppMediumActivityTagByIds(ids));
    }
}
